# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Karol "Kenji Takahashi" Woźniak <kenji.sx>
# Contributor: spider-mario <spidermario@free.fr>
# Contributor: Allen Li <darkfeline at abagofapples.com>

pkgname=flake8
pkgver=6.0.0
pkgrel=3
epoch=1
pkgdesc="The modular source code checker: pep8, pyflakes and co"
arch=('any')
url="https://flake8.pycqa.org"
license=('MIT')
depends=('python-pyflakes' 'python-mccabe' 'python-pycodestyle' 'python-entrypoints')
makedepends=('python-setuptools')
checkdepends=('python-pytest')
source=("https://github.com/PyCQA/flake8/archive/$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('27de4632332ee72bb5deedfcb7ea59e31a3e7fbfd6c165adf019b06cccaba51b776f4310219d8b27cf4894ed2597330fe9c0e381187353d4dc239f102eedd26a')

prepare() {
  sed -i -e 's/,<[0-9=.]*//' flake8-$pkgver/setup.cfg

  sed -i '/error/a \    ignore:Creating a LegacyVersion has been deprecated and will be removed in the next major release:DeprecationWarning' flake8-$pkgver/pytest.ini
}

build() {
  cd flake8-$pkgver
  python setup.py build
}

check() {
  # Hack entry points by installing it

  cd flake8-$pkgver
  python setup.py install --root="$PWD/tmp_install" --optimize=1
  local python_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
  PYTHONPATH="$PWD/tmp_install/usr/lib/python${python_version}/site-packages:$PYTHONPATH" pytest
}

package() {
  cd flake8-$pkgver
  python setup.py install --root="$pkgdir" --prefix=/usr --optimize=1
  install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

# vim:set ts=2 sw=2 et:
